/**
 * 
 */
package edu.towson.cosc603.coffeemaker;

import junit.framework.Assert;
import junit.framework.TestCase;

/**
 * @author Dave
 *
 */
public class InventoryTest extends TestCase {

	/**
	 * @param name
	 */
	CoffeeMaker myCoffeeMaker = null;
	Recipe myRecipe = null;
	
	//public InventoryTest(String name) {
	//	super(name);
	//}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	public void setUp() throws Exception 
	{
		super.setUp();
		//4 new recipes and inventory created when creating coffee machine
		myCoffeeMaker = new CoffeeMaker();
		myRecipe = new Recipe();
		
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	public void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#Inventory()}.
	 */
	/*public void testInventory() {
		fail("Not yet implemented");
	}
*/
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testGetChocolateOnCreation() 
	{
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate());
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testGetChocolateAfterUnitsRemoved() 
	{
		myRecipe.setName("Chocolate");
		myRecipe.setAmtChocolate(2);
		myRecipe.setAmtCoffee(0);
		myRecipe.setAmtMilk(0);
		myRecipe.setAmtSugar(0);
		myRecipe.setPrice(1);
		myCoffeeMaker.makeCoffee(myRecipe, 1);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		testInventory.getChocolate();
		Assert.assertEquals(13, testInventory.getChocolate());
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setChocolate(int)}.
	 */
	public void testSetChocolateUpperLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 2147483632;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testChocolate = testInventory.getChocolate();
		Assert.assertEquals(2147483647, testChocolate); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testSetChocolateLowerLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate()); 
	}
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testSetChocolateNegLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = -1;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate()); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getChocolate()}.
	 */
	public void testSetChocolateWithZeroUnits() 
	{
		//all inventory is created with 15 units
		int amtChocolate = -1;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getChocolate()); 
	}
	
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getCoffee()}.
	 */
	public void testGetCoffeeOnCreation() 
	{
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getCoffee());
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getCoffee()}.
	 */
	public void testGetCoffeeAfterUnitsRemoved() 
	{
		myRecipe.setName("CoffeeCoffee");
		myRecipe.setAmtChocolate(0);
		myRecipe.setAmtCoffee(2);
		myRecipe.setAmtMilk(0);
		myRecipe.setAmtSugar(0);
		myRecipe.setPrice(1);
		myCoffeeMaker.makeCoffee(myRecipe, 1);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		testInventory.getChocolate();
		Assert.assertEquals(13, testInventory.getCoffee());
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}.
	 */
	public void testSetCoffeeUpperLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 2147483632;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testCoffee = testInventory.getCoffee();
		Assert.assertEquals(2147483647, testCoffee); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}.
	 */
	public void testSetCoffeeLowerLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testCoffee = testInventory.getCoffee();
		Assert.assertEquals(15, testCoffee); 
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setCoffee(int)}.
	 */
	public void testSetCoffeeNegLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = -1;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testCoffee = testInventory.getCoffee();
		Assert.assertEquals(15, testCoffee); 
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getMilk()}.
	 */
	public void testGetMilkOnCreation()
	{
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getMilk());
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getMilk()}.
	 */
	public void testGetMilkAfterUnitsRemoved()
	{
		myRecipe.setName("Milk");
		myRecipe.setAmtChocolate(0);
		myRecipe.setAmtCoffee(0);
		myRecipe.setAmtMilk(2);
		myRecipe.setAmtSugar(0);
		myRecipe.setPrice(1);
		myCoffeeMaker.makeCoffee(myRecipe, 1);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		testInventory.getChocolate();
		Assert.assertEquals(13, testInventory.getMilk());
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}.
	 */
	public void testSetMilkUpperLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 2147483632;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testMilk = testInventory.getMilk();
		Assert.assertEquals(2147483647, testMilk); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}.
	 */
	public void testSetMilkLowerLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testMilk = testInventory.getMilk();
		Assert.assertEquals(15, testMilk); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setMilk(int)}.
	 */
	public void testSetMilkNegLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = -1;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testMilk = testInventory.getMilk();
		Assert.assertEquals(15, testMilk); 
		
		
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getSugar()}.
	 */
	public void testGetSugarOnCreation()
	{
		Inventory testInventory = myCoffeeMaker.checkInventory();
		Assert.assertEquals(15, testInventory.getSugar());
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#getSugar()}.
	 */
	public void testGetSugarAfterUnitsRemoved()
	{
		myRecipe.setName("Sugar");
		myRecipe.setAmtChocolate(0);
		myRecipe.setAmtCoffee(0);
		myRecipe.setAmtMilk(0);
		myRecipe.setAmtSugar(2);
		myRecipe.setPrice(1);
		myCoffeeMaker.makeCoffee(myRecipe, 1);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		testInventory.getChocolate();
		Assert.assertEquals(13, testInventory.getSugar());
	}
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}.
	 */
	public void testSetSugarUpperLimit() 
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 2147483632;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testSugar = testInventory.getSugar();
		Assert.assertEquals(2147483647, testSugar); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}.
	 */
	public void testSetSugarLowerLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = 0;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testSugar = testInventory.getSugar();
		Assert.assertEquals(15, testSugar); 
		
		
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#setSugar(int)}.
	 */
	public void testSetSugarNegLimit()
	{
		//all inventory is created with 15 units
		int amtChocolate = 0;
		int amtCoffee = 0;
		int amtMilk = 0;
		int amtSugar = -1;
		myCoffeeMaker.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		Inventory testInventory = myCoffeeMaker.checkInventory();
		int testSugar = testInventory.getSugar();
		Assert.assertEquals(15, testSugar); 
		
		
	}

		
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#enoughIngredients(edu.towson.cosc603.coffeemaker.Recipe)}.
	 */
	public void testEnoughIngredientsSugarNotEnough() 
	{
		//all inventory is created with 15 units
		myRecipe.setName("Chocolate");
		myRecipe.setAmtChocolate(16);
		myRecipe.setAmtCoffee(16);
		myRecipe.setAmtMilk(16);
		myRecipe.setAmtSugar(16);
		myRecipe.setPrice(1);
		myCoffeeMaker = new CoffeeMaker();
		myCoffeeMaker.addRecipe(myRecipe);
		Assert.assertEquals(false, (myCoffeeMaker.checkInventory()).enoughIngredients(myRecipe));
	}

	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.Inventory#toString()}.
	 */
	
	public void testToString() 
	{
		String result = (myCoffeeMaker.checkInventory()).toString();
		Assert.assertEquals("Coffee: 15\nMilk: 15\nSugar: 15\nChocolate: 15\n",result);
	}
}
